<template>
	<view class="notice">
		<view class="cu-chat">
			<view class="cu-item" v-for="(item, index) in noticeList" :key="index">
				<view class="cu-avatar radius"><image src="../../static/img/notice.png" mode=""></image></view>
				<view class="main">
					<view class="content shadow">
						<view v-if="userInfo.role === 'company'">
							<text v-if="item.content">{{ item.content }}</text>
							<text v-else>{{ item.nickName }}向你投递了一份简历，请前往用户中心中查收</text>
						</view>
						<text v-else>{{ item.nickName }}向你发起了面试邀请，请前往用户中心查收</text>
					</view>
				</view>
				<view class="date ">{{ timeFormat(item.createdAt) }}</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
import { updateDeliveryStatus } from '@/apis/delivery/index.js';
import { updateApplyStatus } from '@/apis/apply/apply.js';

export default {
	data() {
		return {};
	},
	computed: {
		...mapState(['noticeList', 'userInfo'])
	},
	mounted() {
		this.$store.commit('UPDATE_DELIVERY_STATUS');
		if (this.userInfo.role === 'company') {
			updateDeliveryStatus({ type: 'all', userId: this.userInfo.id });
		} else {
			updateApplyStatus({ type: 'all', userId: this.userInfo.id });
		}
	},
	methods: {
		// 格式化时间
		timeFormat(value) {
			return uni.$uv.timeFormat(value);
		}
	}
};
</script>

<style lang="scss" scoped>
image {
	width: 100%;
	height: 100%;
	background-color: #f5f5f5;
}
</style>
